//
//  TFUnderlineButton.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/5/5.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFUnderlineButton: UIButton {
    //下划线
    @objc public let underline = UIView()
    override init(frame: CGRect) {
        super.init(frame: frame)

        self.underline.isHidden = true
        self.addSubview(self.underline)
        self.underline.backgroundColor = UIColor(red: 64/255.0, green: 132/255.0, blue: 227/255.0, alpha: 1)

    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        
        self.underline.frame = CGRect(x: 0, y: self.frame.size.height-3, width: self.frame.size.width, height: 0.5)
        
        
        
        let imageViewW = self.frame.size.width*0.5
        let imageViewH = self.frame.size.height*0.5
        let imageViewX = (self.frame.size.width-imageViewW)/2
        let imageViewY = (self.frame.size.height-imageViewH)/2
        self.imageView!.frame = CGRect(x: imageViewX, y: imageViewY, width: imageViewW, height: imageViewH)
       
    }

}
